package cn.lcl.demo.test;


import cn.lcl.common.util.ProUtils;
import org.gjt.mm.mysql.Driver;
import org.testng.annotations.*;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import static org.testng.Assert.assertNotNull;

/**
 * Created by licho on 2017/9/28 0028.
 */
@org.testng.annotations.Test
public class DBConnection {
    /**
     * 测试远程数据库是否连接成功
     */
    public void testDBConnection() throws ClassNotFoundException, SQLException {
        final String driver=ProUtils.getProperty("mysql.driver");
        final String url=ProUtils.getProperty("mysql.url");
        final String user=ProUtils.getProperty("mysql.user");
        final String password= ProUtils.getProperty("mysql.password");
        Class.forName(driver);
        Connection con=DriverManager.getConnection(url,user,password);
        assertNotNull(con);
    }
}
